
package cn.edu.sjtu.software.sjtucontacts.util;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author hujingfei
 *
 */
public class GroupIDGenerator {
	// The maximum id ever used
	private static int usedMaxID = 3;
	// The reclaimed ids
	private static List<Integer> reclaimedIDs = new ArrayList<Integer>();
	
	public static int nextId()
	{
		if (reclaimedIDs.size() == 0)
			return usedMaxID++;
		
		int id = reclaimedIDs.get(reclaimedIDs.size() - 1);
		reclaimedIDs.remove(reclaimedIDs.size() - 1);
		return id;
	}
	
	public static boolean recyleId(int id)
	{
		reclaimedIDs.add(id);
		return true;
	}
	
}

